package com.futao.springboot.learn.api.jmeter;

import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author futao@gmail.com
 * @date 2021/12/16
 */
@Slf4j
@RestController
@RequestMapping("/jmeter")
public class JmeterController {

    @GetMapping("/pre")
    public JSONObject pre() {
        return new JSONObject().fluentPut("username", RandomUtil.randomString(3))
                .fluentPut("mobile", RandomUtil.randomNumbers(11));
    }

    @PostMapping("/service")
    public JSONObject service(@RequestBody JSONObject body) {
        log.info("接收到的值为:{}", body);
        return body;
    }
}
